//---------------------------------------------------------------------------
// Sword3 Engine (c) 1999-2000 by Kingsoft
//
// File:	KBitmap16.h
// Date:	2000.08.08
// Code:	Daniel Wang
// Desc:	Header File
//---------------------------------------------------------------------------

#ifndef K_BITMAP16_H
#define K_BITMAP16_H

#define BM16_SIGNATURE '61MB'
typedef struct 
{
	union
	{
		char	id[4];	// "BM16"
		UINT32	signature;
	};

	INT32	width;
	INT32	height;
	INT32	RGBMask;
} KBMPHEADER16;

class KFILEFMT_CLASS KBitmap16
{
protected:
	krt::AutoBuffer	m_Bitmap;
	int			m_nWidth;
	int			m_nHeight;
public:
	KBitmap16();
	BOOL		init(int nWidth, int nHeight);
	void		free();
	BOOL		load(krt::stream &src);
	BOOL		load(LPCSTR lpFileName);
	BOOL		save(LPCSTR lpFileName);
	void		draw(int x, int y);
	void		DrawLum(int x, int y, int nLum);
	void		clear();
	void		PutPixel(int x, int y, WORD color);
	WORD		GetPixel(int x, int y);
	LPWORD		GetPointer(int x, int y);

public:
	inline void* GetBitmap()	{ return m_Bitmap.GetBuffer(); }
	inline int	GetWidth()	{ return m_nWidth; }
	inline int	GetHeight()	{ return m_nHeight; }
};
//---------------------------------------------------------------------------
#endif	//K_BITMAP16_H
